package nayasis.common.device.input;

import java.util.ArrayList;
import java.util.List;
import java.util.Observable;
import java.util.Observer;


public class GamePadEventObserver implements Observer {

	private List<GamePadEventHandler> eventHandlers = new ArrayList<>();
	
	public GamePadEventObserver( List<GamePadEventHandler> eventHandlers ) {
		this.eventHandlers = eventHandlers;
	}
	
	@Override
	public void update( Observable object, Object argument ) {
		
		if( argument == null || ! (argument instanceof GamePadEvent) ) return;
		
		GamePadEvent event = (GamePadEvent) argument;
		
		for( GamePadEventHandler handler : eventHandlers ) {
			handler.handle( event );
		}
		
	}

}
